import info.gridworld.actor.Bug;
import info.gridworld.grid.Location;

public class ZBug extends Bug{
	private int steps;
	private int sideLength;
	private int turnTimes;
	
	public ZBug(int length) {
		steps = 0;
		sideLength = length;
		turnTimes = 2;
		setDirection(Location.EAST);
	}
	
	public void act() {
		if(turnTimes<=2 && turnTimes>=0 && steps<sideLength) {
			if(canMove()) {
				move();
				steps++;
			}
			
		}
		else if(steps==sideLength) {
			steps = 0;
			turnTimes--;
			if(turnTimes == 1) {
				setDirection(Location.SOUTHWEST);
			}
			if(turnTimes == 0) {
				setDirection(Location.EAST);
			}
		} 
		
	}
}
